package com.kxf.alarmmanagertest

import android.content.IntentFilter
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.kxf.alarmmanagertest.MyAlarmManager.Companion.ALARM_ACTION_CODE

/*
运行以下命令，强制系统进入闲置模式：

    $ adb shell dumpsys deviceidle force-idle

准备就绪后，运行以下命令，使系统退出闲置模式：

    $ adb shell dumpsys deviceidle unforce

执行以下命令，重新激活设备：

    $ adb shell dumpsys battery reset
* */
class MainActivity : AppCompatActivity() {


    private var myReceiver = MyReceiver()

    companion object {// 包裹范围内 属于静态方法
        val TAG = "MainActivity"
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        var intentFilter = IntentFilter()
        intentFilter.addAction(ALARM_ACTION_CODE)
        registerReceiver(myReceiver, intentFilter)

        MyReceiver.myAlarmManager = MyAlarmManager(applicationContext)
    }

    override fun onDestroy() {
        super.onDestroy()
        unregisterReceiver(myReceiver)
    }

}